// leaderPerson/pages/facePayOrderList/facePayOrderList.js
var common = require("../../../common/common.js").common;

Page({
    /**
   * 页面的初始数据
   */
    data: {
        search: {
            page: 1,
            rows: 10
        },
        orderList: []
    },
    /**
   * 生命周期函数--监听页面加载
   */
    onLoad: function(options) {
        this.getOrderList();
    },
    getOrderList() {
        let that = this;
        common.request({
            endpoint: "My/myinfo/my-face-order",
            method: "post",
            data: that.data.search,
            success: function(res) {
                if (res.code == 0) {
                    //有值
                    if (that.data.orderList.length > 0) {
                        if (res.extra.length > 0) {
                            let dd = that.data.orderList.concat(res.extra);
                            that.setData({
                                orderList: dd
                            });
                        }
                    } else {
                        that.setData({
                            orderList: res.extra
                        });
                    }
                    that.setData({
                        "search.page": that.data.search.page + 1
                    });
                } else {
                    wx.showToast({
                        title: res.message
                    });
                }
            }
        });
    },
    /**
   * 生命周期函数--监听页面初次渲染完成
   */
    onReady: function() {},
    /**
   * 生命周期函数--监听页面显示
   */
    onShow: function() {},
    /**
   * 生命周期函数--监听页面隐藏
   */
    onHide: function() {},
    /**
   * 生命周期函数--监听页面卸载
   */
    onUnload: function() {},
    /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
    onPullDownRefresh() {
        console.log(33);
        this.setData({
            orderList: [],
            "search.page": 1
        });
        this.getOrderList();
        wx.stopPullDownRefresh({});
    },
    /**
   * 页面上拉触底事件的处理函数
   */
    onReachBottom() {
        console.log(22);
        this.getOrderList();
    },
    /**
   * 用户点击右上角分享
   */
    onShareAppMessage: function() {}
});